package study.nzy.com.studydemo;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import java.util.List;
import java.util.Map;

public class MainActivity extends Activity {
    String fruitname[] = {"苹果", "香蕉", "樱桃", "葡萄", "芒果", "橘子", "梨", "菠萝", "草莓", "西瓜"};

    GridView gv_items;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gv_items = findViewById(R.id.gv_items);
        gv_items.setAdapter(new MyAapter(this,fruitname,fruitname));
            @Override
            public int getCount() {
                return fruitname.length;
            }

            @Override
            public Object getItem(int i) {
                return fruitname[0];
            }

            @Override
            public long getItemId(int i) {
                return i;
            }

            @Override
            public View getView(int i, View view, ViewGroup viewGroup) {
                View rootView=View.inflate(MainActivity.this,R.layout.simple_dropdown_item_1line);
                TextView text1=rootView.findViewById(android.R.id.text1);

                return rootView;
            }
        });
    }

    class MyAapter extends SimpleAdapter {
        public MyAapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
            super(context, data, resource, from, to);
        }
    }
}
